<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="https://lib.baomitu.com/socket.io/2.0.1/socket.io.js"></script>
    <script src="/static/js/jquery.js"></script>
    <script type="text/javascript">
        $(()=>{
            let socket= io("http://localhost:8360");
            $(".send").click(function (evt){
                let id = $('.myInput').val();
                if(id) {
                    socket.emit('queryUser', id);
                }
            });

            socket.on('open', function(data) {
                console.log('open:', data);
            });

            socket.on('joined', function(data) {
                console.log('joined:', data);
            });

            socket.on('push', function(data) {
                for (let i in data) {
                    $("#push").html("<strong>收到推送内容(" + data[i].id + ":" + data[i].name + ":" + data[i].age + ")</strong>");
                }
            });
        })
    </script>
</head>
<body>
    <button class="send">请求发起</button>
    <input type="text" class="myInput"><br>
    <div name="pushContent" id="push" cols="30" rows="10"></div>
</body>
</html>